from selenium import webdriver
from time import sleep
from selenium.webdriver.common.action_chains import ActionChains
# 创建驱动对象
driver = webdriver.Chrome()
# 窗口最大化
driver.maximize_window()
driver.get("http://www.baidu.com")

# 单击
# 右键单击”百度一下“
#elem = driver.find_element_by_id("su")
# action = ActionChains(driver)
# action.context_click(elem)
# action.perform()
#ActionChains(driver).context_click(elem).perform()
# 左键单击“搜索框”
# elem1 = driver.find_element_by_id("kw")
# ActionChains(driver).click(elem1).perform()

# 拖动
# source = driver.find_element_by_link_text("图片")
# target = driver.find_element_by_id("s-usersetting-top")
# ActionChains(driver).drag_and_drop(source, target).perform()

# 鼠标悬停
# ActionChains(driver).move_to_element(target).perform()
ActionChains(driver).move_to_element(driver.find_element_by_link_text("更多")).perform()
ActionChains(driver).click(driver.find_element_by_link_text("学术")).perform()
sleep(2)
driver.quit()